package com.carmanage.service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import com.carmanage.dao.RoleDao;
import com.carmanage.domain.Page;
import com.carmanage.domain.Role;

@Component
@Service
public class RoleService {

	@Resource
	private RoleDao roleDao;
	
	private List<Role> roles;
	
	public List<Role> findAllRole() {
		// TODO Auto-generated method stub
		roles = roleDao.findAllRole();
		return roles;
	}

	public List<Role> findRoleByPage(Page rolePage) {
		// TODO Auto-generated method stub
		List<Role> roles = roleDao.findRoleByPage(rolePage);
		return roles;	
	}

	public int findAllRoleRecord() {
		// TODO Auto-generated method stub
		int AllRoleRecord = roleDao.findAllRoleRecord();
		return AllRoleRecord;
	}

	public int addRole(String rolename, Date date) {
		// TODO Auto-generated method stub
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");  
		String creatdate=sdf.format(date);
		int i = roleDao.addRole(rolename, creatdate);
		return i;
	}

	public int updateRole(List<Integer> listAction, int roleid) {
		// TODO Auto-generated method stub
		int i = roleDao.updateRole(listAction,roleid);
		
		return i;
	}
    
}
